import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
      alias: {
          "@": resolve(__dirname, 'public'), // 路径别名
      },
      extensions: ['.js', '.json', '.ts'] // 使用路径别名时想要省略的后缀名，可以自己 增减
  },
  server: {
    host: "localhost",
    proxy: {
    '/weather': {
        target: 'http://t.weather.sojson.com/',
        changeOrigin: true,
        ws:true,
        pathRewrite: {
          '^/weather':''
        },
        rewrite: (path) => path.replace(/^\/weather/, '')
      },
      '/api': {
        target: 'http://121.37.29.167:8080/',
        changeOrigin: true,
        ws:true,
        pathRewrite: {
          '^/api':''
        },
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      }
    }  
})


